package controllers.servlets;

import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DownloadServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public static final String BYTES = "BYTES";

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		super.doPost(req, resp);
		byte[] bytes = (byte[]) req.getSession().getAttribute(BYTES);
		OutputStream out = resp.getOutputStream();
		try {
			out.write(bytes);
		} finally {
			out.close();
		}
	}
}
